﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace ConnectToDatabase
{
    public class InsertDB:MarshalByRefObject
    {
        private string cmdtext;
        private ConnectDB connectDB = new ConnectDB();
        
        #region ThemLoaiSanPham
        public int InsertLoaiSanPham(string m_sMaLoaiSP, string m_sTenLoaiSP, int m_siTinhTrang)
        {
            cmdtext = "INSERT INTO dbgiaydep.loaisanpham VALUES('" + m_sMaLoaiSP + "','" + m_sTenLoaiSP + "'," +  m_siTinhTrang + ")";
            return connectDB.QueryData(cmdtext);
        }

        #endregion

        #region ThemSanPham
        public int InsertSanPham(string m_sMaSP, string m_sMaNhomSP, string m_sMaNhapHang, int m_siTinhTrang)
        {

            cmdtext = "INSERT INTO dbgiaydep.sanpham VALUES('" + m_sMaSP + "','" + m_sMaNhomSP + "','" +
                      m_sMaNhapHang + "'," + m_siTinhTrang + ")";
            return connectDB.QueryData(cmdtext);

        }  
        #endregion

        #region ThemDauSanPham
        public int InsertDauSanPham(string m_sMaDauSP, string m_sMaLoaiSP, string m_sTenDauSP, string m_sNhaPhanPhoi, int m_siGiaBan, int m_siThoiHanBan, int m_siTinhTrang)
        {

            cmdtext = "INSERT INTO dbgiaydep.dausanpham VALUES('" + m_sMaDauSP + "','" + m_sMaLoaiSP + "','" +
                      m_sTenDauSP + "','" + m_sNhaPhanPhoi + "'," + m_siGiaBan + "," + m_siThoiHanBan + "," +
                      m_siTinhTrang + ")";
            return connectDB.QueryData(cmdtext);
        }  
        #endregion

        #region ThemNhomSanPham
        public int InsertNhomSanPham(string m_sMaNhomSP, string m_sMaDauSP, string m_sMauSac, float m_sfKichThuoc, int m_siSoLuongHienTai)
        {

            cmdtext = "INSERT INTO dbgiaydep.nhomsanpham VALUES('" + m_sMaNhomSP + "','" + m_sMaDauSP + "','" +
                      m_sMauSac + "'," + m_sfKichThuoc + "," + m_siSoLuongHienTai + ")";
            return connectDB.QueryData(cmdtext);

        }
        #endregion

        #region ThemNhaPhanPhoi
        public int InsertNhaPhanPhoi(string m_sMaNhaPP, string m_sTenNhaPP, int m_siTinhTrang)
        {

            cmdtext = "INSERT INTO dbgiaydep.nhaphanphoi VALUES('" + m_sMaNhaPP + "','" + m_sTenNhaPP + "'," +
                      m_siTinhTrang + ")";
            return connectDB.QueryData(cmdtext);
        }  
        #endregion

        #region ThemPhieuNhapHang
        public int InsertPhieuNhapHang(string m_sMaNhapHang, string m_sdtNgayNhapHang, int m_siTongTien)
        {
            cmdtext = "INSERT INTO dbgiaydep.phieunhaphang VALUES('" + m_sMaNhapHang + "','" +
                      m_sdtNgayNhapHang + "'," +
                      m_siTongTien + ")";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region PhieuTraHang
        public int InsertPhieuTraHang(string m_sMaPhieuTra, string m_sdtNgayTra)
        {
            cmdtext = "INSERT INTO dbgiaydep.phieutrahang VALUES('" + m_sMaPhieuTra + "','" +
                      m_sdtNgayTra + "')";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemNhanVien
        public int InsertNhanVien(string m_sMaNV, string m_sMaLoaiNV, string m_sHoTen, int m_siTinhTrang)
        {
            cmdtext = "INSERT INTO dbgiaydep.nhanvien VALUES('" + m_sMaNV + "','" + m_sMaLoaiNV + "','" +
                      m_sHoTen + "'," + m_siTinhTrang + ")";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemLoaiNhanVien
        public int InsertLoaiNhanVien(string m_sMaLoaiNV, string m_sTenLoaiNV, int m_siTinhTrang)
        {
            cmdtext = "INSERT INTO dbgiaydep.loainhanvien VALUES(" + "'" + m_sMaLoaiNV + "','" + m_sTenLoaiNV +
                      "'," + m_siTinhTrang + ")";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemKhuyenMai
        public int InsertKhuyenMai(string m_sMaPhieuKM, string m_sMaDauSP, string m_sNoiDungKM, int m_siPTGiamGia, string m_sdtNgayBatDau, string m_sdtNgayKetThuc)
        {
            cmdtext = "INSERT INTO dbgiaydep.khuyenmai VALUES(" + "'" + m_sMaPhieuKM + "','" + m_sMaDauSP + "','" + m_sNoiDungKM + "','" + m_siPTGiamGia + "','" + m_sdtNgayBatDau + "', '" + m_sdtNgayKetThuc + "')";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemHoaDon
        public int InsertHoaDon(string m_sMaHD, string m_sdtNgayBan, int m_siThanhTien, int m_iLoaiKH, string m_sMaNV)
        {
            cmdtext = "INSERT INTO dbgiaydep.hoadon VALUES('" + m_sMaHD + "','" + m_sdtNgayBan + "'," + m_siThanhTien +
                      "," + m_iLoaiKH + ",'" + m_sMaNV + "')";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemDichVuBaoHang
        public int InsertDVBaoHanh(string m_sMaDVBaoHanh, string m_sMaHD, string m_sMaSP, string m_sdtNgayNhan, string m_sdtNgayTra, string m_sHoTenKH, string m_sCMND, int m_siPhiPhatSinh)
        {
            
            cmdtext = "INSERT INTO dbgiaydep.dv_baohanh VALUES('" + m_sMaDVBaoHanh + "','" + m_sMaHD + "','" + m_sMaSP +
                      "','" + m_sdtNgayNhan + "','" + m_sdtNgayTra + "','" + m_sHoTenKH + "','" + m_sCMND + "'," +
                      m_siPhiPhatSinh + ")";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemDangNhap
        public int InsertDangNhap(string m_sMaDN, string m_sMaNV, string m_sdtThoiGianNhap, string m_sdtThoiGianXuat)
        {
            cmdtext = "INSERT INTO dbgiaydep.dangnhap VALUES('" + m_sMaDN + "','" + m_sMaNV + "','" + m_sdtThoiGianNhap +
                      "','" + m_sdtThoiGianXuat + "')";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemChiTietPhieuTra
        public int InsertCtPhieuTra(string m_sMaPT, string m_sMaSP, string m_sThongTinLoi)
        {
            cmdtext = "INSERT INTO dbgiaydep.ct_phieutrahang VALUES('" + m_sMaPT + "','" + m_sMaSP + "','" +
                      m_sThongTinLoi + "')";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemChiTietPhieuNhap
        public int InsertCTPhieuNhap(string m_sMaNhapHang, string m_sMaNhomSP, int m_siSoLuong, int m_siGiaVon)
        {
            cmdtext = "INSERT INTO dbgiaydep.ct_phieunhaphang VALUES('" + m_sMaNhapHang + "','" + m_sMaNhomSP + "'," +
                      m_siSoLuong + "," + m_siGiaVon + ")";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        #region ThemChiTietHoaDon
        public int InsertCTHoaDon(string m_sMaHD, string m_sMaSP, int m_siDonGiaBan)
        {
            cmdtext = "INSERT INTO dbgiaydep.ct_hoadon VALUES('" + m_sMaHD + "','" + m_sMaSP + "'," + m_siDonGiaBan +
                      ")"; 
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        public int Test() { return 0; }
    }
}
